<?php

/**
 * Aktív résztvevők, akik a kurzuson részt vesznek.
*
* @author Zsolt Lengyel
*
* @property string recommendation
*
*/
class ActiveRegistration extends Registration{

    /**
     *
     * @param string $className
     * @return ActiveRegistration
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * (non-PHPdoc)
     * @see CActiveRecord::init()
     */
    public function init(){
       parent::init();
       $this->type = self::ACTIVE;

    }

    public function behaviors() {
        return CMap::mergeArray(parent::behaviors(), array(
                'recommendationBehavior' => array(
                        'class' => 'FileARBehavior',
                        'attribute' => 'recommendation', // this must exist
                        'extension' => 'pdf, doc, docx, png, jpg, jpeg', // possible extensions, comma separated
                        'prefix' => 'trombita_kurzus_2013_', // if you want a prefix
                        'relativeWebRootFolder' => 'files/recommendations', // this folder must exist
                        //'defaultName' => 'default', // you can also use a default file (see Ingredients with image below).
                )
        ));
    }

    /**
     * (non-PHPdoc)
     * @see CActiveRecord::defaultScope()
     */
    function defaultScope(){
        return array(
                'condition'=>"t.type=:type",
                'params'=>array(':type'=>self::ACTIVE)
        );
    }

    public function rules(){

       return CMap::mergeArray(parent::rules(), array(
             array('studies, musics, results', 'required', 'message'=> 'Kötelező mező.'),

             array('recommendation', 'file', 'types'=> 'pdf, doc, docx, png, jpg, jpeg'),
             ));

    }

}